package org.example;

/**
 * Hello world!
 *
 */

import org.example.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

public class App 
{

        @Autowired
        private OrderService orderService;

        public static void main(String[] args) {
            SpringApplication.run(Homework6Application.class, args);
        }

        @Override
        public void run(String... args) throws Exception {
            System.out.println("🧪 开始测试 AOP 功能...\n");

            try {
                orderService.add("iPhone", 2);
            } catch (Exception e) {
                System.out.println("🚫 add 被中断: " + e.getMessage());
            }

            System.out.println();

            try {
                orderService.delete("AirPods");
            } catch (Exception e) {
                System.out.println("🚫 delete 被中断: " + e.getMessage());
            }

            System.out.println();

            try {
                orderService.find("MacBook");
            } catch (Exception e) {
                System.out.println("🚫 find 被中断: " + e.getMessage());
            }
        }

}

